﻿using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace _029
{
    class Box
    {
        private double length;//长度
        private double breadth;//宽度
        private double height;//高度
        public double getVolume()//返回值为空计算体积
        {
            return length * breadth * height;
        }
        public void setLength(double len)
        {
            length = len;
        }
        public void setBreadth(double bre)
        {
            breadth = bre;
        }
        public void setHeight(double hei)
        {
            height = hei;
        }
        //重载+运算符，把两个Box对象相加
        public static Box operator +(Box b, Box c)
        {
            Box box = new Box();
            box.length = b.length + c.length;
            box.breadth = b.breadth + c.breadth;
            box.height = b.height + c.height;
            return box;
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            Box box1 = new Box();//声明Box1，类型为Box
            Box box2 = new Box();//声明Box2,类型为Box
            Box box3 = new Box();//声明Box3，类型为Box
            double volume = 0.0;//体积
            //box1详述
            box1.setLength(6.0);
            box1.setBreadth(7.0);
            box1.setHeight(5.0);

            //box2详述
            box2.setLength(12.0);
            box2.setBreadth(13.0);
            box2.setHeight(10.0);

            //box1的体积
            volume = box1.getVolume();
            Console.WriteLine("box1的体积为：{0}",volume);

            //box2的体积
            volume = box2.getVolume();
            Console.WriteLine("box2的体积：{0}",volume);

            //把两个对象相加
            box3 = box1 + box2;

            //bo3的体积
            volume = box3.getVolume();
            Console.WriteLine("box3的体积：{0}",volume);
            Console.ReadKey();
        }
    }
}
